//
//  UIBarButton+Extension.swift
//  SinaWeibo
//
//  Created by 李江波 on 2016/11/12.
//  Copyright © 2016年 lijiangbo. All rights reserved.
//

import UIKit

extension UIBarButtonItem{

    convenience init(title : String = "", imageName : String, taget : Any?, action : Selector?) {
        self.init()
        
        let btn = UIButton()
        btn.setImage(UIImage(named: imageName), for: .normal)
        btn.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
        
        btn.setTitle(title, for: .normal)
        btn.setTitleColor(UIColor.darkGray, for: .normal)
        btn.setTitleColor(UIColor.orange, for: .highlighted)
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
        
        btn.sizeToFit()
        btn.addTarget(taget, action: action!, for: .touchUpInside)
        
        customView = btn
        
    }

}
